#ifndef RFM01_H
 #define RFM01_H

#include "main.h"


#define F_CPU 16000000UL
#include <util/delay.h>

#define RF_PORT	PORTB
#define RF_DDR	DDRB
#define RF_PIN	PINB

#define SDI		5	// SDI,  -> RF02
#define SCK		7	// SCK,  -> RF02
#define CS		4	// nSEL, -> RF02
#define SDO		6	// SDO,  <- RF02

// nFFS: 1-10k Pullup an Vcc !!!

#ifndef cbi
#define cbi(sfr, bit)     (_SFR_BYTE(sfr) &= ~_BV(bit)) 
#endif
#ifndef sbi
#define sbi(sfr, bit)     (_SFR_BYTE(sfr) |= _BV(bit))  
#endif



extern void rf01_trans(unsigned short wert);
extern void rf01_init(void);
extern void rf01_setbandwidth(unsigned char bandwidth);
extern void rf01_setreceiver(unsigned char gain, unsigned char drssi);
extern void rf01_setfreq(unsigned short freq);
extern void rf01_setbaud(unsigned short baud);
extern void rf01_rxdata(unsigned char *data, unsigned char number);

void init_rfm();
void transmit_rfm(uint16_t cData);

#define RF01FREQ(freq)	((freq-430.0)/0.0025)

#endif


